package main

import (
	"flag"
	"google.golang.org/grpc"
	"log"
	"net"
	"shop/common/config"
	"shop/common/inits"
	"shop/shop_grpc/internal/handler"
	"shop/shop_grpc/proto/shop"
)

func main() {
	config.Init()
	inits.InitRedis()
	inits.InitMysql()
	inits.InitNacos()
	//inits.InitElasticsearch() // 初始化ES客户端
	flag.Parse()

	lis, err := net.Listen("tcp", "127.0.0.1:50051")
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	shop.RegisterShopServer(s, &handler.Server{})
	log.Printf("server listening at %v", lis.Addr())
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}
